package com.ruoyi.web.controller.bussiness;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.entity.po.TVisionVote;
import com.ruoyi.service.IVisionVoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/visionVote")
@Api(tags = "PC-8.视觉投票管理")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class VisionVoteController extends BaseController {

    private final IVisionVoteService visionVoteService;


    @GetMapping("/list")
    @ApiOperation("获取视觉投票列表")
    public TableDataInfo list(TVisionVote visionVote) {
        return getDataTable(visionVoteService.selectTVisionVoteList(visionVote));
    }

    @GetMapping("/getVoteInfo")
    @ApiOperation("获取视觉投票信息")
    public AjaxResult getVoteInfo(Long id) {
        return AjaxResult.success(visionVoteService.selectTVisionVoteById(id));
    }

    @PostMapping("/add")
    @ApiOperation("新增视觉投票")
    public AjaxResult add(@RequestBody TVisionVote visionVote) {
        return toAjax(visionVoteService.insertTVisionVote(visionVote));
    }

    @PostMapping("/edit")
    @ApiOperation("修改视觉投票")
    public AjaxResult edit(@RequestBody TVisionVote visionVote) {
        return toAjax(visionVoteService.updateTVisionVote(visionVote));
    }

    @PostMapping("/delete")
    @ApiOperation("删除视觉投票")
    public AjaxResult delete(@RequestBody Integer[] ids) {
        return toAjax(visionVoteService.deleteTVisionVotes(ids));
    }

}
